#ifndef INC_DIAGRAMFAM_H
#define INC_DIAGRAMFAM_H

#include "../model/UMLDiagram.h" // clients will need this
#include "../model/DiagramVisitor.h"
#include "../view/UMLCanvas.h"
#include "Acceptor.h"

#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
#include <vector>
#include <QXmlStreamReader> // FIXME: don't include here

class UMLBox;
class UMLLine;

/**
 * A happy family of a UMLDiagram and associated objects.
 *
 * Note: Not copyable because we don't want to copy the canvas!
 */
class DiagramFam : public boost::noncopyable
{
	public:
		/**
		 * @param diagram the family now owns your pointer
		 * @param canvasParent constructed canvas will have this parent
		 */
		DiagramFam(UMLDiagram*, QWidget* canvasParent);

		/**
		 * Construct a DiagramFam from an XML file.
		 */
		DiagramFam(const QString& path, QWidget* canvasParent);

		/*** ACCESSORS ***/

		UMLDiagram& diagram();

		/**
		 * @return the DiagramFam-owned UMLCanvas associated with the diagram
		 */
		UMLCanvas& canvas();
		Acceptor& acceptor();

		const QString& path() const;
		void setPath(const QString&);

		const QString& name() const;

		/*** FILE MANIPULATION ***/

		void save() const;

	private:
		boost::scoped_ptr<UMLDiagram> _diagram;
		UMLCanvas _canvas;
		Acceptor _acceptor;

		QString _path;
		QString _name;

		/*** XML PARSING ***/

		void read();

		/**
		 * Called to process a token we don't recognize.
		 * @return true if parsing should stop
		 */
		void processDefault(QXmlStreamReader& reader);

		void readBumlf(QXmlStreamReader& reader);
		UMLBox readBox(QXmlStreamReader& reader);
		UMLLine readLine(QXmlStreamReader& reader);
		std::vector<QPoint> readVertices(QXmlStreamReader& reader);
		QPoint readPoint(QXmlStreamReader& reader);
		QSize readSize(QXmlStreamReader& reader);
		BUMLSText readProperties(QXmlStreamReader& reader);
};

#endif // INC_DIAGRAMFAM_H

